package com.jinghong.epidemiccontrolproject.controller;

import com.jinghong.epidemiccontrolproject.pojo.PageBean;
import com.jinghong.epidemiccontrolproject.pojo.Region;
import com.jinghong.epidemiccontrolproject.pojo.Result;
import com.jinghong.epidemiccontrolproject.service.RegionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName:RegionController
 * Package:com.jinghong.epidemiccontrolproject.controller
 * Description:
 *
 * @Author: 寻月君子
 * @CreatTime:2024/1/19 22:41
 * Version:1.0
 */
@Slf4j
@RestController
@RequestMapping("/region")
public class RegionController {
        @Autowired
        private RegionService regionService;
        @GetMapping
        public Result page(@RequestParam(defaultValue = "1") Integer page,
                           @RequestParam(defaultValue = "10") Integer pageSize,
                           String name){
            log.info("分页查询, 参数: {},{},{}",page,pageSize,name);
            PageBean pb = regionService.page(page,pageSize,name);
            return Result.success(pb);

        }
        @PostMapping
        public Result add(@RequestBody Region region){
            log.info("添加地区, 参数: {}",region);
            String name = region.getName();
            regionService.add(name);
            return Result.success();
        }



}
